function createPoliceContractWindow()
	-- Police contract window
	wndPoliceContract = guiCreateWindow(0.3469,0.2862,0.2914,0.35,"Contract Details: Police Officer",true)
	guiSetAlpha(wndPoliceContract,0.80000001192093)
	guiWindowSetSizable(wndPoliceContract,false)
	txtPoliceContractDetails = guiCreateMemo(15,31,343,174,"Do YOU want to become a police officer? Being a police officer is not easy: you can get shout at or attacked by people. But the nice thing about it is that you can kill other people. All in the name of law and order. So get your police baton ready, unholster your gun and shoot some bad guys!",false,wndPoliceContract)
	guiSetAlpha(txtPoliceContractDetails,1)
	guiMemoSetReadOnly(txtPoliceContractDetails,true)
	txtPoliceContractDetails = guiCreateLabel(15,209,343,16,"Be warned: Screw up, and you WILL get fired!",false,wndPoliceContract)
	guiSetAlpha(txtPoliceContractDetails,1)
	guiLabelSetColor(txtPoliceContractDetails,255,255,255)
	guiLabelSetVerticalAlign(txtPoliceContractDetails,"top")
	guiLabelSetHorizontalAlign(txtPoliceContractDetails,"center",false)
	btnPoliceContractAccept = guiCreateButton(15,233,167,33,"Accept Job",false,wndPoliceContract)
	guiSetAlpha(btnPoliceContractAccept,1)
	btnPoliceContractReject = guiCreateButton(211,233,147,33,"Reject Job",false,wndPoliceContract)
	guiSetAlpha(btnPoliceContractReject,1)
	
	guiSetVisible(wndPoliceContract, false)
	
	addEventHandler("onClientGUIClick", btnPoliceContractReject, clientPoliceContractReject, false)
	addEventHandler("onClientGUIClick", btnPoliceContractAccept, clientPoliceContractAccept, false)
end

-- Create the marker and blip for the job
copMarker = createMarker (1553.56, -1675.54, 16.20 - 1, "cylinder", 1.2, 0, 0, 255, 255, getRootElement())
copBlip = createBlip (1553.56, -1675.54, 16.20 - 1, 30, 2, 255, 0, 0, 255, 0, 500)

function showPoliceContract(hitPlayer, matchingDimension)
	if getElementType (hitPlayer) == "player" and hitPlayer == getLocalPlayer() then
		if (source == copMarker) then
			createPoliceContractWindow()
			if (wndPoliceContract ~= nil) then
				guiSetVisible (wndPoliceContract, true)
			else
				outputChatBox ("The contract window could not be loaded. Contact an admin please.")
			end
			showCursor (true)
			guiSetInputEnabled (true)
		end
	end
end

function clientPoliceContractAccept(button, state)
	if button == "left" and state == "up" then
		triggerServerEvent("acceptCop", getLocalPlayer())
		guiSetInputEnabled(false)
		guiSetVisible(wndPoliceContract, false)
		showCursor(false)
	end
end

function clientPoliceContractReject(button, state)
	if button == "left" and state == "up" then
		outputChatBox("You rejected the job.")
		guiSetInputEnabled(false)
		guiSetVisible(wndPoliceContract, false)
		showCursor(false)
	end
end

addEventHandler("onClientMarkerHit", copMarker, showPoliceContract)